
import { VxeGridPropTypes } from "vxe-table/types/grid";

export const columnsOfGoods: VxeGridPropTypes.Columns = [
  // {type: 'seq', title: '序号', treeNode: false, visible: false, width: 60,},
  // {field: 'ID', title: 'ID', width: 60, visible: false,},
  {field: 'cate.name', title: '类别', sortable: false, width: 'auto',},
  {field: 'code', title: '货物编号', sortable: false,width: 'auto'},
  {field: 'name', title: '货物名称', sortable: false,width: 'auto'},
  {field: 'unit', title: '单位', sortable: false, visible: false, width: 'auto',},
  {field: 'specs', title: '规格', sortable: false, visible: false, width: 'auto',},
  {field: 'barcode', title: '条码', sortable: false, visible: false, width: 'auto',},
  {field: 'warehouse.name', title: '仓库/库区', sortable: false, width: 'auto',},
  {field: 'sumQty', title: '库存量', sortable: true, width: 'auto',},
  {field: 'memo', title: '备注', visible: false, sortable: false, width: 'auto',},
];

export const columnsOfWarehouse: VxeGridPropTypes.Columns = [
  // {type: 'seq', title: '序号', treeNode: false, visible: false, width: 60,},
  // {field: 'ID', title: 'ID', width: 60, visible: false,},
  {field: 'warehouseName', title: '仓库', sortable: false, visible: true,},
  {field: 'warehouseAreaName', title: '库区', sortable: false, visible: true,},
  {field: 'cate.name', title: '类别', sortable: false, width: 'auto',},
  {field: 'code', title: '货物编号', sortable: false,width: 'auto'},
  {field: 'name', title: '货物名称', sortable: false,width: 'auto'},
  {field: 'unit', title: '单位', sortable: false, visible: false, width: 'auto',},
  {field: 'specs', title: '规格', sortable: false, visible: false, width: 'auto',},
  {field: 'barcode', title: '条码', sortable: false, visible: false, width: 'auto',},
  {field: 'sumQty', title: '库存量', sortable: true, width: 'auto',},
  {field: 'memo', title: '备注', visible: false, sortable: false, width: 'auto',},
];

/**
 * 迭代 禁用不可用的分类
 * @param parent 商品分类列表
 * @returns 
 */
export function deep(parent:any[]) {
  parent.forEach(e => {
    e.disabled = e.enable !== 1
    e.checked = false
    if (e.attrs && e.attrs.length > 0) {
      e.attrs.forEach(a => a.checked = false)
    }
    if (e.children && e.children.length > 0) deep(e.children)
  })
  return parent
}

